/**
 * @Author zhuyuping
 * @Date 2020-05-12 18:49
 * @type javaScript
 */
/**
 * 获取地址栏参数
 * @param name
 * @returns {*}
 * @constructor
 */
function GetQueryString(name) {
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  var r = window.location.search.substr(1).match(reg);
  if (r != null)return unescape(r[2]);
  return null;
}
function initPage(){
  const channel = GetQueryString("channel");
  var obj = {
    acction: "1",
    orderNo: GetQueryString("orderNo"),
    payTime: GetQueryString("payTime"),
    payAmount: GetQueryString("payAmount"),
    merchantNo: GetQueryString("merchantNo"),
    orderSeq: GetQueryString("orderSeq"),
    orderStatus: GetQueryString("orderStatus"),
    signData: GetQueryString("signData"),
  };
  if(!obj.orderNo){
    document.write("<br />订单号不能为空<br />");
    return
  }
  if(!channel){
    document.write("<br />渠道不能为空<br />");
    return
  }
  // App
  if(channel === "1"){
    try {
      window.ReactNativeWebView.postMessage(JSON.stringify(obj));
    } catch (e){
      document.write("<br />云端物业管理App，跳转出错<br />");
      document.write("<br />请点击左上角返回<br />");
    }
    return
  }
  // 小程序
  if(channel === "2"){
    try {
      wx.miniProgram.navigateTo({url: "./../pay_details/index?orderNo="+ obj.orderNo+"&payAmount="+ obj.payAmount+"&payTime="+ obj.payTime})
    } catch (e){
      document.write("<br />云端物业管理小程序，跳转出错<br />");
      document.write("<br />请点击左上角返回<br />");
    }
    return
  }
  //  阿克苏政府
  if(channel === "6"){
    window.location.href = "http://zwm.silkrdata.com/hybrid/html/closeme.html?type=lsgwater&l_COMPNO="+ obj.orderNo;
    return
  }
  document.write("渠道有误，请检查渠道！");
}
initPage();